﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MqttAnalyze.Data.Models
{
    [SugarTable("TB_MSG_TEMPLATE")]
    public class MqttMessageTemplateTb
    {
        [SugarColumn(ColumnName = "TPL_ID", IsPrimaryKey = true)]
        public string TemplateId { get; set; }
        [SugarColumn(ColumnName = "TPL_NAME")]
        public string TemplateName { get; set; } = null!;
        [SugarColumn(ColumnName = "TOPIC")]
        public string Topic { get; set; } = null!;
        [SugarColumn(ColumnName = "CONTENT")]
        public string Message { get; set; } = null!;
        [SugarColumn(ColumnName = "IS_RETAIN")]
        public bool IsRetain { get; set; }
        [SugarColumn(ColumnName = "QOS")]
        public int Qos { get; set; }
    }

    [SugarTable("TB_RECVMSG_CATEGORY")]
    public class MqttMessageCategoryTb
    {
        [SugarColumn(ColumnName = "CAT_ID", IsPrimaryKey = true)]
        public string CategoryId { get; set; }
        [SugarColumn(ColumnName = "TOPIC")]
        public string Topic { get; set; } = null!;
        [SugarColumn(ColumnName = "CATEGORY")]
        public string Category { get; set; } = null!;
        [SugarColumn(ColumnName = "SAVE_NUM")]
        public int KeepNum { get; set; }
    }

    [SugarTable("TB_RECVMSG")]
    public class MqttRecvMessageTb
    {
        [SugarColumn(ColumnName = "MSG_ID", IsPrimaryKey = true)]
        public string MessageId { get; set; }

        [SugarColumn(ColumnName = "CAT_ID")]
        public string CategoryId { get; set; }


        [SugarColumn(ColumnName = "SUB_CLASS")]
        public string SubClass { get; set; }

        [SugarColumn(ColumnName = "TOPIC")]
        public string Topic { get; set; } = null!;
        [SugarColumn(ColumnName = "CONTENT")]
        public string Message { get; set; } = null!;
        [SugarColumn(ColumnName = "RECV_TIME")]
        public string RecvTime { get; set; } = null!;
    }


    public class RecvMessageCategory: RecvTopicCategory
    {
        public string CategoryId { get; set; }

        public string Topic { get; set; } = null!;

        public string Classify { get; set; } = null!;

        public int KeepNum { get; set; }

        public List<string> SubClass { get; set; } = new List<string>();

        public List<MqttMessage> MsgList { get; set; } = new List<MqttMessage>();
    }

    public class MqttMessage
    {
        public string SubClass { get; set; } = null!;
        public string Content { get; set; } = null!;

        public string RecvTime { get; set; } = null!;
    }

    public class RecvMessage: MqttMessage
    {
        public string Topic { get; set; } = null!;
    }

    public class RecvTopicCategory
    {
        public string CategoryId { get; set; }

        public string Topic { get; set; } 

        public string Classify { get; set; } 

        public int KeepNum { get; set; }
    }

    public class MqttRecvMessage
    {
        public string CategoryId { get; set; }

        public string SubClass { get; set; }

        public string Topic { get; set; } 
        public string Content { get; set; }

        public string RecvTime { get; set; } 
    }
}
